﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//new
using DataRecv.enums;

namespace DataRecv
{
    public partial class Form_diyfolder : Form
    {
        public string diy;

        public Form_diyfolder()
        {
            InitializeComponent();
        }

        private void Form_diyfolder_Load(object sender, EventArgs e)
        {
            try
            {
                this.label_diy.Text = diy;
                string[] dd = null;
                if ((diy != null) && (diy != ""))
                {
                    dd = diy.Split('\\');
                }
                this.flowLayoutPanel1.Controls.Clear();

                string[] ss = Enum.GetNames(typeof(Enum_DiySubFolder));
                if (ss != null)
                {
                    foreach (string s in ss)
                    {
                        CheckBox box = new CheckBox();
                        box.Text = s;
                        if (dd != null)
                        {
                            foreach (string d in dd)
                            {
                                if (d == s)
                                {
                                    box.Checked = true;
                                    break;
                                }
                            }
                        }
                        box.CheckedChanged += new EventHandler(box_CheckedChanged);
                        this.flowLayoutPanel1.Controls.Add(box);
                    }
                }

            }
            catch { }
        }

        void box_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                CheckBox box = sender as CheckBox;
                if (box.Checked == true)
                {
                    if (this.label_diy.Text == "")
                    {
                        this.label_diy.Text += box.Text;
                    }
                    else
                    {
                        this.label_diy.Text += ("\\" + box.Text);
                    }
                }
            }
            catch { }
        }

        private void button_reset_Click(object sender, EventArgs e)
        {
            try
            {
                this.label_diy.Text = "";
                if ((this.flowLayoutPanel1.Controls != null) && (this.flowLayoutPanel1.Controls.Count > 0))
                {
                    foreach (Control c in this.flowLayoutPanel1.Controls)
                    {
                        ((CheckBox)c).Checked = false;
                    }
                }
            }
            catch { }
        }

        private void button_save_Click(object sender, EventArgs e)
        {
            try
            {
                diy = this.label_diy.Text;
                this.Close();
            }
            catch { }
        }
    }
}
